# 定义函数
def add():
    """两数相加"""
    print("输入两个数字，我会帮你计算它们的和")
    print("输入'q'退出")
    while True:
        try:
            first_num = input("请输入第一个数字：")
            if first_num == 'q':
                break
            first_num = float(first_num)
            second_num = input("请输入第二个数字：")
            if second_num == 'q':
                break
            second_num = float(second_num)
        except ValueError:
            print("输入类型有误：请重新输入")
            continue
        else:
            print(f"{first_num} + {second_num} = {first_num + second_num}")


# 调用函数
add()